package cmd

import (
	"gitee.com/xuender/se"
	"github.com/fatih/color"
	"github.com/spf13/cobra"
)

// nolint: gochecknoinits
func init() {
	sizeCmd := &cobra.Command{
		Use:     "size",
		Aliases: []string{"z"},
		Short:   "显示数据库占用空间",
		Long:    `显示数据库的磁盘空间占用情况.`,
		Run: func(cmd *cobra.Command, args []string) {
			ctx := se.NewContext(cmd)

			color.White(
				"数据库目录: %s",
				ctx.DataBasePath,
			)
			color.Red(se.FormatFileSize(se.Size(ctx.DataBasePath)))
		},
	}

	rootCmd.AddCommand(sizeCmd)
}
